/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package lc3vm;

/**
 *
 * @author Administrator
 */
import javax.swing.*;
import java.awt.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;


public class PanelMemoria extends JPanel {

    private static JTable table = new JTable();
    private static String[] encabezado = {"Dirección","Instrucción","Instrucción","Etiqueta"};
    private static DefaultTableModel tablemodel = new DefaultTableModel(Memoria.getLineas(),encabezado);
    private static JScrollPane barras;
    private static TableColumn columna = null;

    public PanelMemoria(){
       table.setModel(tablemodel);
       barras = new JScrollPane(table);
       barras.createHorizontalScrollBar();
       barras.setPreferredSize(new Dimension(600,200));
       columna = table.getColumnModel().getColumn(0);
       columna.setPreferredWidth(20);
       columna = table.getColumnModel().getColumn(2);
       columna.setPreferredWidth(20);
       add(barras);
       
    }

    public static void updateMemoria(){
        String[][] s = Memoria.getLineas();

        for(int i = 0; i < Memoria.getCantLineas(); i++)
            for(int j = 0; j < 4; j++)
                tablemodel.setValueAt(s[i][j], i, j);
    }
}